<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .table-border tbody tr td{
         border-top: 1px solid black;
    }
</style>
<section class="content-header">
    <h1>报价单审核</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <input  type="hidden" name="verifyInfoId" th:value="${sysUserModel.verifyInfoId}">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>项目编号</label>
                                    <input type="text" name="proCode" class="form-control" placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" name="proName" class="form-control" placeholder="请输入项目名称">
                                </div>
                                <div class="form-group" >
                                    <label>报价状态</label>
                                    <select name="appStatus" class="form-control">
                                        <option value="">全部</option>
                                        <option value=1 selected="selected">未审核</option>
                                        <option value=2>已审核</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>创建人</label>
                                    <input type="text" name="createName" class="form-control" placeholder="请输入创建人姓名">
                                </div>
                                <div class="form-group">
                                    <label>创建日期</label>
                                    <input type="text" class="form-control datepicker" name="quoteStartDate">
                                    <span>至</span>
                                    <input type="text" class="form-control datepicker"  name="quoteEndDate">
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">&emsp;搜索&emsp;</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"  class="table-border" ></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var table;
    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "quoteManage/quoteApprove/list",
            showColumns: true,
            showExport: true,
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '项目编号', field: 'proCode', width: '120',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value.split(',').join('<br>');
                        }
                    }
                },
                {title: '项目名称', field: 'proName', width: '300',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value.split(',').join('<br>');
                        }
                    }
                },
                {title: '物料名称', field: 'proNames', width: '300',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value.split(',').join('<br>');
                        }
                    }
                },
                {title: '买方名称', field: 'consumerName', width: '250px'},
                // {title: '任务组', field: 'groupName', width: '100',
                //     formatter: function (value, row, index) {
                //         if (value != null) {
                //             return value.split(',').join('<br>');
                //         }
                //     }
                // },

                // {title: '报价任<br>务状态', field: 'quoteProcessStatus', width: '100',
                //     formatter: function (value, row, index) {
                //         if (value === 1) {
                //             return '<span class="badge ' + ["label-default"] + '">' + '未开始' + '</span> ';
                //         }else if (value === 2) {
                //             return '<span class="badge ' + ["label-info"] + '">' + '执行中' + '</span> ';
                //         }else if(value === 3){
                //             return '<span class="badge ' + ["label-success"] + '">' + '已完成' + '</span> ';
                //         }
                //     }
                // },
                {title: '审核状态', field: 'appStatus', width: '100',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '<span class="badge ' + ["label-default"] + '">' + '未审核' + '</span> ';
                        }else if(value === 2){
                            return '<span class="badge ' + ["label-success"] + '">' + '审核通过' + '</span> ';
                        }else if(value === 0){
                            return '<span class="badge ' + ["label-danger"] + '">' + '审核驳回' + '</span> ';
                        }
                    }
                },

                // {title: '报价单号', field: 'quoteNo', width: '120'},
                {title: '含税</br>总金额(元)', field: 'totalAmountIncludedTax', width: '120px'},

                {title: '创建人', field: 'createName', width: '100px'},
                {title: '创建日期', field: 'quoteGentDate', width: '150px'},
                // {title: '审核明细', field: 'appDetail', width: '200px',
                //         formatter: function (value, row, index) {
                //             if (value != null) {
                //                 return value.split(',').join('<br>');
                //             }
                //         }
                // },
                {title: '操作', field:'operation', width: '140px',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if ((row.quoteStatus == 2 || row.quoteStatus == 3) && row.appStatus == 1 ) {
                            if (row.nowNode === [[${sysUserModel.verifyInfoId}]] && [[${sysUserModel.account}]] != 'admin' && [[${sysUserModel.verifyInfoId}]] != null) {
                                if (hasP("quo:audit:check")) {
                                    actions.push('<a class="btn btn-success btn-xs" href="' + ctx + 'quoteManage/appQuotation/quoteId/' + row.quoteId + '"> 审核</a>');
                                }
                            } else {
                                if(hasP("quo:await:view")) {
                                    actions.push('<a class="btn btn-info btn-xs" href="' + ctx + 'quoteManage/viewQuotation/quoteId/' + row.quoteId + '">查看</a> ');
                                }
                            }
                        }else if((row.quoteStatus == 2 || row.quoteStatus == 3) && row.appStatus != 1){
                            if(hasP("quo:await:view")) {
                                actions.push('<a class="btn btn-info btn-xs" href="' + ctx + 'quoteManage/viewQuotation/quoteId/' + row.quoteId + '">查看</a> ');
                            }
                        }
                        else if (row.quoteStatus == 4 || row.quoteStatus == 5) {
                            if(hasP("quo:await:view")) {
                                actions.push('<a class="btn btn-info btn-xs" href="' + ctx + 'quoteManage/viewQuotation/quoteId/' + row.quoteId + '">查看</a> ');
                            }
                        }
                        return actions.join('');
                    }
                }
            ]
        });

        /** 验证 */
        // js.validate.init("halfAdjEditForm", {
        //     fields: {
        //         aadAfterNum: {validators:
        //                 {notEmpty: {message: '请输入在库数量'},
        //                     digits: {message: '请输入数值'}}}
        //         //aadAfterPrice:{validators: {digits: {message: '请输入数值'}}},
        //         //aadAfterUnit: {validators: {notEmpty: {message: '未输入单位'}}},
        //     }
        // });

        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        // js.modal.hideEvent("modal-edit", function () {
        //     js.validate.reset("halfAdjEditForm");
        //     js.reset("halfAdjEditForm");
        // });
    });
</script>
</body>
</html>